"""
@Project ：TpShopVerifyCodeOCR 
@File    ：QQEmailSwitchToIframeTest.py
@IDE     ：PyCharm 
@Author  ：张成龙
@Date    ：2024/10/9 11:22 
@explain ：
"""
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.microsoft import EdgeChromiumDriverManager

driver = webdriver.Edge(EdgeChromiumDriverManager().install())
driver.implicitly_wait(10)
driver.maximize_window()
driver.get("https://mail.qq.com/")

iframe1 = driver.find_element(By.CLASS_NAME, "QQMailSdkTool_login_loginBox_qq_iframe")
driver.switch_to.frame(iframe1)

iframe2 = driver.find_element(By.NAME, 'ptlogin_iframe')
driver.switch_to.frame(iframe2)

# 定位到密码登录，并使用邮箱进行登录
driver.find_element(By.XPATH, '//*[@id="switcher_plogin"]').click()

driver.find_element(By.ID, "u").send_keys("1814957922@qq.com")

time.sleep(3)

driver.switch_to.default_content()